<%--
  Created by IntelliJ IDEA.
  User: kuankuan
  Date: 2023/3/7
  Time: 9:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <script src="/js/jquery-1.12.4.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <style>
        body {
            background: none repeat scroll 0 0 #D8EDFC;
            margin: 0;
            padding: 0;
        }
        .page a{
            text-decoration: none;
            padding: 5px 10px;
            cursor: pointer;
        }

        .page a:hover{
            background-color: cornflowerblue;
        }

        .page ：active{
            background-color: palevioletred;
        }

    </style>
</head>

<body>
<div>
</div>
<table width="600" align="center"  class="table table-striped table table-bordered">
    <caption>餐桌</caption>
    <thead>
    <th>table_id</th>
    <th>table_name</th>
    <th>table_status</th>
    <th width="200">操作</th>
    </thead>
    <tbody>
    <c:forEach var="dinner_table" items="${requestScope.pageBean1.datas}">
        <c:if test="${dinner_table.table_status!=1}">
            <tr>
                <td>${dinner_table.table_id}</td>
                <td>${dinner_table.table_name}</td>
                <c:choose>
                    <c:when test="${dinner_table.table_status==2}">
                        <td>正在使用</td>
                    </c:when>
                    <c:otherwise>
                        <td>可预订</td>
                    </c:otherwise>
                </c:choose>
                <td>
                    </a>
                    <a onclick="UpdateUser('${dinner_table.table_name}', ${dinner_table.table_id})">预定</a>
                </td>
            </tr>
        </c:if>
    </c:forEach>
    <tr>
        <td colspan="4" align="center">
            <h2 style="background-color: red;width: 310px;">取消预约请联系管理员</h2>
        </td>
    </tr>
    </tbody>
</table>
        <a href="/userlook1">返回上一页</a><br>

<script>
    function UpdateUser(name, id){
        if(confirm('是否预定'+name+"?")) {
            alert("预定成功")
            open('/dinner_table1?action=update&table_status=1&table_id='+id,'_self')
        }
    }
    function UpdateUser1(name, id){
        if(confirm('是否取消预定'+name+"?")) {
            alert("取消成功")
            open('/dinner_table1?action=update&table_status=0&table_id='+id,'_self')
        }
    }

    onload = function () {
        if('${sessionScope.delMsg}' !== ''){
            alert('${sessionScope.delMsg}')
            fetch("/dinner_table1?action=delMsg");
        }
    }
</script>
</body>
</html>
